/**
 * @file ringBuffer.h
 * @author your name (you@domain.com)
 * @brief AI 生成，但是不需要预留一格判断是否为满，通过 count 计数
 * @version 0.1
 * @date 2025-06-26
 * 
 * @copyright Copyright (c) 2025
 * 
 */

#ifndef _RING_BUFFER_H_
#define _RING_BUFFER_H_

#include <stdio.h>
#include "main.h"

struct ringBufferStu {
    uint8_t *buffer;     // 缓冲区指针
    const uint8_t size;  // 缓冲区大小
    uint8_t head;        // 头指针
    uint8_t tail;        // 尾指针
    uint8_t count;       // 当前数据量
};

// int ringBuffer_init(struct ringBufferStu *ringBuffer, uint8_t *buffer, const uint8_t size);
int ringBuffer_push(struct ringBufferStu *ringBuffer, uint8_t data);
int ringBuffer_pop(struct ringBufferStu *ringBuffer, uint8_t *data);
int ringBuffer_peek_head(struct ringBufferStu *ringBuffer, uint8_t *data);
int ringBuffer_peek_tail(struct ringBufferStu *ringBuffer, uint8_t *data);
int ringBuffer_is_empty(struct ringBufferStu *ringBuffer);
int ringBuffer_is_full(struct ringBufferStu *ringBuffer);
int ringBuffer_clear(struct ringBufferStu *ringBuffer);
int ringBuffer_get_count(struct ringBufferStu *ringBuffer);

#endif // _RING_BUFFER_H_
